﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Core.Interfaces;
using Core.Interfaces.IPresenters;

namespace Core.Views
{
    public partial class DataView : Form, IAbstractDataView
    {
        public string ViewName
        {
            get { return this.Text; }
            set { this.Text = value; }
        }

        public BindingSource Data
        {
            get { return iBuildingBindingSource; }
            set { iBuildingBindingSource = value; }
        }
        public DataView()
        {
            InitializeComponent();
            dataGridView1.AutoGenerateColumns = true;
        }

        public event EventHandler AddRecord;
        public event EventHandler Refreh;
        public event EventHandler DeleteRecord;
        public event EventHandler UpdateRecord;

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (DeleteRecord != null)
            {
                DeleteRecord(this, null);
            }
        }

        private void addButton_Click(object sender, EventArgs e)
        {
            if (AddRecord != null)
                AddRecord(this, null);
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            if (Refreh != null)
            {
                Refreh(this, null);
            }
        }

        private void DataView_Activated(object sender, EventArgs e)
        {
            if (Refreh != null)
            {
                Refreh(this, null);
            }
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            if (UpdateRecord != null)
            {
                UpdateRecord(this, null);
            }
        }
    }
}
